//This file is part of SimpleReportingTool
//
//SimpleReportingTool is free software: you can redistribute it and/or modify
//it under the terms of the GNU Lesser General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//SimpleReportingTool is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License
//along with Foobar.  If not, see <http://www.gnu.org/licenses/>.



#include "cSimpleReportingTool.h"
#include "cDataSourceCVS.h"
#include "cReportTargetPDF.h"
#include "cReportTargetHTML.h"


#include <cstdio>
#include <cstdlib>


int main(void)
{
	string ReportTemplate;
	string CSVdataBuffer;
	FILE* fp;

	fopen_s(&fp,"../TestReport/Report.xml","r");
	while(!feof(fp))
	{
		ReportTemplate += fgetc (fp);
	}
	fclose(fp);
	

	fopen_s(&fp,"../TestReport/simpledata.csv","r");
	while(!feof(fp))
	{
		CSVdataBuffer += fgetc (fp);
	}
	fclose(fp);

	

	// initialize Report engine
	cSimpleReportingTool ReportEngine;
	
	// set report template
	ReportEngine.SetReportXMLBuffer(ReportTemplate.c_str());
	
	// set data source
	cDataSourceCVS data( "Global",CSVdataBuffer.c_str());
	ReportEngine.SetDataSource(&data);

	// set report target
	cReportTargetHTML* ReportTarget = new cReportTargetHTML();
	ReportEngine.Report(ReportTarget);
	ReportTarget->Close();
	ReportTarget->Save("../TestReport/ReportTarget.html");

	/*cText prova("ciao",10,20);

	ReportTarget->DrawText(&prova);
	ReportTarget->DrawBox(50,50,200,300);
	ReportTarget->Close();*/
	
	

	//system("PAUSE");
	return 0;

}
